<include file="public@header" />
<style>
	.expander{margin-left: -20px;}
	.action_ul{overflow:hidden; font-size:15px; font-family:'黑体'; margin:10px 0px;}
	.action_ul li{padding:0px 10px; display:inline;text-align:center; float:left; cursor:pointer}
	.action_ul li img{margin:5px 0; width: 18px}
	.action_ul li p{margin: 0 0 5px;}
	.visua_div{border:2px solid #E3EEF4; white-space: nowrap;overflow-x: auto; height: 100%;}
	.visua_child{position:relative;display: inline-block;width:155px; height:140px; border-radius:10px; margin:3px; text-align:center; padding:15px 0 10px 0; vertical-align: text-top;}
	.visua_child input{margin: 0 2px; background:#fff}
	.visua_child p{margin: 0 0 3px;}
	.borderRight{border-right:2px solid #ccc}
	.bg_qianlv{background-color:#E9FEC0;}
	.bg_huanglv{background-color:#808000;}
	.bg_lan{background-color:#8080FF;}
	.bg_cheng{background-color:#F7E1CC;}
	.bg_hui{background-color:#E6E6E6;}
	.bg_bai{background-color:#fff; border:1px solid #000}
	.bg_lv{background-color:#00CC00;}
	.bg_huang{background-color:#F3D776;}
	.bg_red{background-color:#FF6699;}
	.bg_mei{background-color:#E792E0;}
	.bg_blue{background-color:#33CCFF;}
	.gege{width:15px; height:15px; float:left; margin:0 3px}
	.visua_child img{position:absolute; margin-top:-15px; left:85%; width:15px; height:15px}

</style>
</head>
<body>
<php>$vo['id']=''</php>
	<div class="wrap js-check-wrap">
		<ul class="nav nav-tabs">
        	<li><a href="{:url('cemetery/index')}">{:lang('ADMIN_CEMETERY_INDEX')}</a></li>
			<li><a href="{:url('cemetery/add')}">{:lang('ADMIN_CEMETERY_ADD')}</a></li>
			<li class="active"><a href="">{:lang('ADMIN_TOMBAREA_INDEX')}</a></li>
		</ul>
		<form class="js-ajax-form" action="{:url('Tombarea/listorders')}" method="post">
			<table class="table table-hover table-bordered table-list" id="menus-table">
				<thead>
					<tr>
						<th>{:lang('NAME')}</th>
						<th>{:lang('POSITION')}</th>
						<th>{:lang('TYPE')}</th>
						<th>{:lang('DISTRIBUTED')}</th>
						<th width="200">{:lang('排序')}</th>
						<th width="280">{:lang('ACTIONS')}</th>
					</tr>
				</thead>
				<tbody>
				<foreach name="results" item="vo">
					<tr>
<!--						<td>{$vo.name} <input type="text" class="title-input"></td>-->
						<td><input autocomplete="off" class='form-control title-input' name='name' data-node="{$vo.id}" value="{$vo.name}">
							<span class="loading-tips nowrap full-width"></span>
						</td>
						<td >{$vo.first_name}</td>
						<td >{$vo.cate_name}</td>
						<td >{$vo.row}行</td>
						<td><input autocomplete="off" type="number" style="width: 100px;" class='form-control title-input' name='list_order' data-node="{$vo.id}" value="{$vo.list_order}"></td>
						<td>
							<a href="javascript:;" name="title" id="{$vo.id}" data-title="{$vo.name}" data-parent="3" class="child-of-node-3}">查看可视化墓位</a>
							|<a href="{:url('Tombarea/delete',array('id'=>$vo['id'],))}" class="js-ajax-delete">{:lang('DELETE')}</a>
						</td>
					</tr>
				</foreach>
				</tbody>
			</table>
		</form>
	</div>
<script>
var index_type  = 1;
</script>
	<script type="text/javascript" src="__STATIC__/js/admin.js?v={:time()}"></script>
<script type="text/javascript" src="__STATIC__/js/init_base.js"></script>
	<script>
		var index_type  = 1;
		$(document).ready(function() {
			Wind.css('treeTable');
			Wind.use('treeTable', function() {
				$("#menus-table").treeTable({
					indent : 20
				});
			});
		});

		$('input.title-input').on('blur', function () {

            var data = {name: this.name, value:  this.value, node: this.getAttribute('data-node')};
			layer.load('更新数据...');
			$.ajax({
				url: "{:url('Visua/tombareacol')}?ajax=1",
				type: "post",
				dataType: "json",
				data: data,
				success: function (result) {
					layer.close()
					if (result.code === 0) {
						layer.msg('更新异常');
					}else {
						layer.msg('更新完成');
						// layer.closeAll()
						reloadPage(window);
					}
				}
			})
		});

		setInterval(function() {
			var refersh_time = getCookie('refersh_time_admin_menu_index');
			if (refersh_time == 1) {
				reloadPage(window);
			}
		}, 1000);
		setCookie('refersh_time_admin_menu_index', 0);


        $(document).on("click","[name='title']",function(){
            // alert($(this).attr("id"));
            if($(this).data("parent") != 3){
                return;
            }
            var id = $(this).attr("id");
            var title = $(this).data("title");
            $('#addTombarea').attr("data-id",id);
            $.ajax({
                url		: "{:url('Visua/tombareacol')}",
                type	: "post",
                dataType: "json",
                data	: {'id':id,'Ajax': 1},
                success : function(result){
                    console.log(result.data)
					var html = "\n" +
                        "                            <div style=\" overflow:hidden; background:#F7F7F7; padding:5px 10px\">\n" +
                        "                                <div class=\"bg_qianlv gege\"></div><span style=\"float:left\">无规划</span>\n" +
                        "                                <div class=\"bg_huanglv gege\"></div><span style=\"float:left\">无产品</span>\n" +
                        "                                <div class=\"bg_blue gege\"></div><span style=\"float:left\">空闲</span>\n" +
                        "                                <div class=\"bg_cheng gege\"></div><span style=\"float:left\">已认购</span>\n" +
                        "                                <div class=\"bg_lv gege\"></div><span style=\"float:left\">定金</span>\n" +
                        "                                <div class=\"bg_huang gege\"></div><span style=\"float:left\">购买未使用</span>\n" +
                        "                                <div class=\"bg_mei gege\"></div><span style=\"float:left\">部分安葬</span>\n" +
                        "                                <div class=\"bg_red gege\"></div><span style=\"float:left\">全部安葬</span>\n" +
                        "                                <div class=\"bg_hui gege\"></div><span style=\"float:left\">迁墓中</span>\n" +
                        "                                <div class=\"bg_bai gege\"></div><span style=\"float:left\">已隐藏</span>\n" +
                        "                            </div>"
                    html +="<div class='visua_div'>";

                    if(result.data.length > 0){
                        $.each(result.data, function(i, n){
                            if (n.cate_id==2){
                                $('.ys').css("display","block");
                            } else {
                                $('.ys').css("display","none");
                            }
                            $.each(n.col, function(y, m){
                                if(m.status == 1){
                                    switch (m.col_status) {
                                        case 1:html+="<div class='visua_child bg_blue'>";break;
                                        case 2:html+="<div class='visua_child bg_cheng'>";break;
                                        case 3:html+="<div class='visua_child bg_lv'>";break;
                                        case 4:html+="<div class='visua_child bg_qianlv'>";break;
                                        case 5:html+="<div class='visua_child bg_huang'>";break;
                                        case 6:html+="<div class='visua_child bg_mei'>";break;
                                        case 7:html+="<div class='visua_child bg_red'>";break;
                                        case 8:html+="<div class='visua_child bg_hui'>";break;
                                        default:html+="<div class='visua_child bg_huanglv'>";break;
                                    }
                                }else{
                                    html+="<div class='visua_child bg_bai'>";
                                }

								 if (m.reacher != ''  &&  m.reacher != null) {
									if (m.login_id != 1  || m.login_id != 5) {
										html += "<img src='__TMPL__/Public/assets/images/peo.png' name='diding' title='抵顶人姓名:" + m.reacher + "'/>";
									} else {
										html += "<div style='position: absolute; right: 5%;top: 1%; color: #13227a;' name='diding'>" + m.reacher + "</div><p></p>";
									}
								} else {
									// html += "<div style='position: absolute; right: 5%;top: 1%; color: #13227a;'>" + m.reacher + "</div><p></p>";
								}
                                html+="<p>"+m.num+"</p>";
                                if(m.tomb_regulation == 1){
                                    html+="<p>单穴</p>";
                                }else if(m.tomb_regulation == 2){
                                    html+="<p>双穴</p>";
                                }else if(m.tomb_regulation == 3){
                                    html+="<p>三穴</p>";
                                }
                                if(m.selling_price) {
                                    html += "<p>单价:" + m.selling_price + "</p>";
                                }
                                html += "</div>";

                            })
                            html+="<br />";
                        })
                    }


                    html+="</div>";

                    RCABase.initBase.ajaxLayerOpen(
                        [title+'-墓位信息', 'color:#383838;font-size:16px;'],
                        html,
                        ['1050px','650px']);

                },
                error	: function(){
                    alert("服务器内部错误，请联系系统管理员");
                }
            });
        })
	</script>
</body>
</html>